package com.cskaoyan.controller.user;

import com.cskaoyan.bean.bo.UserListBo;
import com.cskaoyan.bean.common.BaseParam;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.common.User;
import com.cskaoyan.bean.po.MarketUser;
import com.cskaoyan.bean.vo.DashboardVo;
import com.cskaoyan.service.user.DashboardService;
import com.cskaoyan.service.user.UserManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jzp
 * @since 2022/11/19 19:24
 */
@RestController
@RequestMapping("admin/user/")
public class UserManageController {
    @Autowired
    UserManageService userManageService;

    @RequestMapping("list")
    public BaseRespVo list(UserListBo userListBo) {
        CommonData<MarketUser> userInfo = userManageService.list(userListBo);
        if (userInfo == null) {
            return BaseRespVo.invalidData();
        }
        return BaseRespVo.succeed(userInfo);
    }


    @RequestMapping("detail")
    public BaseRespVo detail(User user) {
        MarketUser userInfo = userManageService.detail(user);
        if (userInfo == null) {
            return BaseRespVo.succeed(null);
        }
        return BaseRespVo.succeed(userInfo);
    }
    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketUser marketUser) {
        boolean userInfo = userManageService.update(marketUser);
        if (!userInfo) {
            return BaseRespVo.succeed(0);
        }
        return BaseRespVo.succeed(1);
    }


}
